package com.cw.jeeyt.service.converter.system;

import java.util.ArrayList;
import java.util.List;

import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.service.bo.system.SystemContactUsBo;
import com.cw.jeeyt.dao.model.system.SystemContactUsDo;
import com.cw.lang.common.utils.CollectionUtil;

/**
 * 联系我们转换类
 *
 * @author chenw
 * @date 2019-03-10 13:04:25
 */
public class SystemContactUsConverter {

    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static SystemContactUsBo do2Bo(SystemContactUsDo model) {
        if (model == null) {
            return null;
        }
        SystemContactUsBo bo = new SystemContactUsBo();
        bo.setId(model.getId());
        bo.setCorpName(model.getCorpName());
        bo.setCorpAddr(model.getCorpAddr());
        bo.setCorpPost(model.getCorpPost());
        bo.setCorpTel(model.getCorpTel());
        bo.setCorpFax(model.getCorpFax());
        bo.setCorpBusiEmail(model.getCorpBusiEmail());
        bo.setCorpMaintainTel(model.getCorpMaintainTel());
        bo.setCorpComplaintCall(model.getCorpComplaintCall());
        bo.setCorpComplaintEmail(model.getCorpComplaintEmail());
        bo.setCorpComment(model.getCorpComment());
        bo.setCreateBy(model.getCreateBy());
        bo.setCreateDate(model.getCreateDate());
        bo.setUpdateBy(model.getUpdateBy());
        bo.setUpdateDate(model.getUpdateDate());
        return bo;
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static SystemContactUsDo bo2Do(SystemContactUsBo bo) {
        if (bo == null) {
            return null;
        }
        SystemContactUsDo model = new SystemContactUsDo();
        model.setId(bo.getId());
        model.setCorpName(bo.getCorpName());
        model.setCorpAddr(bo.getCorpAddr());
        model.setCorpPost(bo.getCorpPost());
        model.setCorpTel(bo.getCorpTel());
        model.setCorpFax(bo.getCorpFax());
        model.setCorpBusiEmail(bo.getCorpBusiEmail());
        model.setCorpMaintainTel(bo.getCorpMaintainTel());
        model.setCorpComplaintCall(bo.getCorpComplaintCall());
        model.setCorpComplaintEmail(bo.getCorpComplaintEmail());
        model.setCorpComment(bo.getCorpComment());
        model.setCreateBy(bo.getCreateBy());
        model.setCreateDate(bo.getCreateDate());
        model.setUpdateBy(bo.getUpdateBy());
        model.setUpdateDate(bo.getUpdateDate());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<SystemContactUsBo> doList2BoList(List<SystemContactUsDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), SystemContactUsConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<SystemContactUsDo> boList2DoList(List<SystemContactUsBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), SystemContactUsConverter::bo2Do));
    }
}